{% extends 'base' %}

{% if servers %}
    {% set ths = ['服务器','IP:PORT','描述','实时状况'] %}
    {% set active_page = "server_list" %}
{% elif locations %}
    {% set ths = ['地点','描述','其他记录','操作'] %}
    {% set active_page = "location_list" %}
{% elif webs is defined %}
    {% set ths=['网站','所在服务器','描述','实时状况'] %}
    {% set active_page = "web_list" %}
{% elif users %}
    {% set ths=['用户名', '真实姓名','管理'] %}
    {% set active_page = 'user_list' %}
{% endif %}

{% block title %}
{{ ths[0] }}列表
{% endblock %}

{% block content %}

<ul class="breadcrumb">
    <li><a href="/">网站后台</a><span class="divider">/</span></li>
    <li class="active">{{ ths[0] }}<span class="divider">/</span></li>
</ul>

<div>
    <table class="table table-hover">
        <tr>
            {% for th in ths %}
                <th>{{ th }}</th>
            {% endfor %}
        </tr>
        {% if servers %}
            {% for server in servers %}
            <tr>
                <td><a href="/server/detail/{{ server._id }}/">{{ server.name }}</a></td>
                <td>{{ server.ip }}</td>
                <td>{{ server.description }}</td>
                <td>
                    {% if server.status_now == 0 %}
                        <span class="label label-success">正常</span>
                    {% elif server.status_now == 1 %}
                        <span class="label label-important">无法连接</span>
                    {% else %}
                        <span class="label">等候初始化</span>
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
        {% endif %}
        {% if locations %}
            {% for location in locations %}
                <tr>
                    <td><a href="/location/detail/{{ location._id }}/">{{ location.location }}</a></td>
                    <td>{{ location.description }}</td>
                    <td>{{ location.notes }}</td>
                    <td>
                        <a href="/temp/{{ location._id }}/">温度</a>|
                        <a href="/location/update/{{ location._id }}/">修改</a>|
                        <a href="/location/delete/{{ location._id }}/">删除</a>
                    </td>
                </tr>
            {% endfor %}
        {% endif %}
        {% if webs %}
            {% for web in webs %}
                <tr>
                    <td><a href="/web/detail/{{ web._id }}/">{{ web.name }}</a></td>
                    <td><a href="/server/detail/{{ web.server_ID }}/" target="_blank">{{ web.server_name }}</a></td>
                    <td>{{ web.description }}</td>
                    <td>
                    {% if web.status_now == 0 %}
                        <span class="label label-success">正常</span>
                    {% elif web.status_now == 1 %}
                        <span class="label label-important">无法连接</span>
                    {% elif web.status_now == 2 %}
                        <span class="label label-important">url类型错误</span>
                    {% else %}
                        <span class="label">等候初始化</span>
                    {% endif %}
                    </td>
                </tr>
            {% endfor %}
        {% endif %}
        {% if users %}
            {% for user in users %}
                <tr>
                    <td>{{ user.username }}</td>
                    <td>{{ user.real_name }}</td>
                    <td>
                        <a href="/user/update/{{ user._id }}/" class="btn btn-small btn-inverse">编辑用户</a>
                        <a href="/user/delete/{{ user._id }}/" class="btn btn-small btn-danger">删除用户</a>
                    </td>
                </tr>
            {% endfor %}


        {% endif %}

    </table>

</div>

{% endblock %}